package com.hx.petsever.controller;

import com.hx.petsever.config.Result;
import com.hx.petsever.entity.Info;
import com.hx.petsever.service.InfoService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/info")
public class InfoController {

    @Autowired
    InfoService infoService;

    @RequestMapping("/get")
    public Result getInfo(@Param("userid") String userid)
    {
        Result<Object> result = new Result<>();
        if(infoService.getInfo(userid) == null)
            result.fail();
        else{
            result.success();
            result.setData(infoService.getInfo(userid));
        }
        return result;
    }

    @RequestMapping("/update")
    public Result updateInfo(Info info)
    {
        Result<Object> result = new Result<>();
        Info update = infoService.update(info);
        result.success();
        result.setData(update);
        return result;
    }
}
